﻿using System;
using System.Collections.Generic;
using System.Text;

namespace HttpAssiant.Utils
{
    
    public class EncodePwd
    {
        private static string VdKy1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

        public static string encodeForPwd(string V2)
        {
            string s3="";
            byte fapXPYTDM4, Se5, LFpuqfCc6, fFkKqMU7, Atgh8, cQOqgsbl9, cYHoFcL10;
            
            int mVKze11 = 0;
            byte[] V2Bytes = System.Text.Encoding.Default.GetBytes(V2);

            do
            {
                fapXPYTDM4 = V2Bytes[mVKze11++];
                Se5 = V2Bytes[mVKze11++];
                LFpuqfCc6 = V2Bytes[mVKze11++];

                fFkKqMU7 = (byte)(fapXPYTDM4 >> 2);
                Atgh8 = (byte)((fapXPYTDM4 & 3) << 4 | Se5 >> 4);
                cQOqgsbl9 = (byte)((Se5 & 15) << 2 | LFpuqfCc6 >> 6);
                cYHoFcL10 = (byte)(LFpuqfCc6 & 63);
                if (Se5 == 0)
                {
                    cQOqgsbl9 = cYHoFcL10 = 64;
                }
                else if (LFpuqfCc6 == 0)
                {
                    cYHoFcL10 = 64;
                }

                s3 = s3 + VdKy1.Substring(fFkKqMU7, 1) + VdKy1.Substring(Atgh8,1) + VdKy1.Substring(cQOqgsbl9,1) + VdKy1.Substring(cYHoFcL10,1);
                fapXPYTDM4 = Se5 = LFpuqfCc6 = 0; fFkKqMU7 = Atgh8 = cQOqgsbl9 = cYHoFcL10 = 0;
            }
            while (mVKze11 < V2.Length);
            return s3;
        }
    }
}
